package com.jspgou.cms.dao.impl;

import org.hibernate.Criteria;
import org.springframework.stereotype.Repository;

import com.jspgou.common.hibernate3.HibernateBaseDao;
import com.jspgou.common.page.Pagination;
import com.jspgou.cms.dao.ShopLevelDao;
import com.jspgou.cms.entity.ShopLevel;
import com.jspgou.cms.entity.ShopTuijanproduct;

@Repository
public class ShopLevelDaoImpl extends HibernateBaseDao<ShopLevel, Long> implements ShopLevelDao {
	public Pagination getPage(int pageNo, int pageSize) {
		Criteria crit = createCriteria();
		Pagination page = findByCriteria(crit, pageNo, pageSize);
		return page;
	}

	public ShopLevel findById(Long id) {
		ShopLevel entity = get(id);
		return entity;
	}

	public ShopLevel save(ShopLevel bean) {
		getSession().save(bean);
		return bean;
	}

	public ShopLevel deleteById(Long id) {
		ShopLevel entity = super.get(id);
		if (entity != null) {
			getSession().delete(entity);
		}
		return entity;
	}
	
	@Override
	protected Class<ShopLevel> getEntityClass() {
		return ShopLevel.class;
	}

	public ShopLevel[] updateOrder(Long[] ids, Integer[] priority) {
		ShopLevel[] beans = new ShopLevel[ids.length];
		for (int i = 0, len = ids.length; i < len; i++) {
			beans[i] = findById(ids[i]);
			beans[i].setLvorder(priority[i]);
		}
		return beans;
	}
}